package day2;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

//新版try-catch 实现文件复制
public class TestCopy2 {
    public static void main(String[] args) {
        //try(){}catch{}
        //可以将需要关闭资源的内容放入()编写  它会帮你自动关闭
        try (FileInputStream fis = new FileInputStream("d://io//2025.0623.mp4");
             FileOutputStream fos = new FileOutputStream("d://io//movie//new2_2025.0623.mp4")
        ){
            long start = System.currentTimeMillis();
            byte[] bs = new byte[1024];
            int len = 0;
            while ((len = fis.read(bs))!=1){
                fos.write(bs,0,len);
            }
            long end = System.currentTimeMillis();
            System.out.println((end-start)+"ms");
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
